home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 8296 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.8 KB  |  84 lines

  1. Path: news.jhu.edu!news
  2. From: Chenyang Xu <chenyang@mashie.ece.jhu.edu>
  3. Newsgroups: comp.lang.c
  4. Subject: C compiling question
  5. Date: Sat, 02 Mar 1996 18:09:51 -0500
  6. Organization: ECE Department, The Johns Hopkins University
  7. Message-ID: <3138D53F.41C6@mashie.ece.jhu.edu>
  8. NNTP-Posting-Host: 128.220.14.190
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 2.0 (X11; I; IRIX 5.2 IP22)
  13.  
  14. Hi, there,
  15.  
  16. I have three files here called: foo.c, foo1.c, foo2.c 
  17.  
  18. ===foo.c===
  19.  
  20. void print_msg1();
  21. void print_msg2();
  22.  
  23. main()
  24. {
  25.   print_msg1();
  26.   print_msg2();
  27. }
  28.  
  29. ===foo1.c===
  30. #include "stdio.h"
  31. #include "math.h"
  32.  
  33. void print_msg1()
  34. {
  35.   float x = 1.0;
  36.   float y;
  37.  
  38.   y = exp(x);
  39.   printf("foo1.c\n");  
  40.   printf("%f\n", y);  
  41.  
  42.   return;
  43. }
  44.  
  45. ===foo2.c===
  46. void print_msg2()
  47. {
  48.   printf("foo2.c\n");  
  49.   print_msg1();
  50.   return;
  51. }
  52.  
  53.  
  54. After compiling with "cc foo.c foo1.c foo2.c -lm -o foo", then type foo
  55. gives me
  56.  the following result:
  57.  
  58. foo1.c
  59. 2.718282
  60. foo2.c
  61. foo1.c
  62. 2.718282
  63.  
  64. My question is how the print_msg2() knows print_msg1() and carrys out
  65. the result
  66.  without causing a compiling or linking error or warning, 
  67.  
  68. Thanks for any help.
  69.  
  70. -- 
  71. Chenyang
  72.  
  73.                               \\|//
  74.                               (o o)
  75.  --------------------------ooO-(_)-Ooo----------------------------------
  76.    (o) 410-516-6819             |   Fax:410-516-5566
  77.    chenyang@jhu.edu             |   http://iacl.ece.jhu.edu/~chenyang      
  78.          _________________________________________________________
  79.         /          Image Analysis and Communication Lab          /
  80.        /   Department of the  Electric and Computer Engineering /
  81.       /         The Johns Hopkins University                   /  
  82.      /             Baltimore, MD 21218                        /
  83.  =======================================================================
  84.